//
//  LSNewfeatureViewController.m
//  ZLFastDoctor
//
//  Created by 李宗帅 on 16/5/29.
//  Copyright © 2016年 LS. All rights reserved.
//

#import "LSNewfeatureViewController.h"
#import "MORootNavigationController.h"
#import "XZGRegisterViewController.h"
#import <Masonry/Masonry.h>
@interface LSNewfeatureViewController ()

@end

@implementation LSNewfeatureViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self setupUI];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)setupUI {
    UIImageView *imageView = [[UIImageView alloc]init];

    imageView.frame = CGRectMake(0, 0, NQScreenW, NQScreenH);
    
    imageView.image = [UIImage imageNamed:@"20150110105032223.jpg"];
    
    [self.view addSubview:imageView];
    
    //  1. 第一种方式： NavBar:本身就有一种毛玻璃效果
    UINavigationBar *navBar = [[UINavigationBar alloc] init];
    
    navBar.barStyle = UIBarStyleBlack;
    
    [navBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
    
    [imageView addSubview:navBar];
    //  设置约束
    [navBar mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(imageView);
    }];
    
    
    
    
    // 添加立即体验按钮
    [self setupStartButton:imageView];
}

- (void)setupStartButton:(UIImageView *)imageView {
    
    imageView.userInteractionEnabled = YES;
    // 创建按钮
    UIButton *startButton = [[UIButton alloc] init];
    // 设置背景图片
    [startButton setBackgroundImage:[UIImage imageNamed:@"guide_start"] forState:UIControlStateNormal];
    // 设置frame
    startButton.frame = CGRectMake(0, 0, startButton.currentBackgroundImage.size.width, startButton.currentBackgroundImage.size.height);
    // 设置中心点位置
    startButton.center = CGPointMake(imageView.frame.size.width * 0.5, imageView.frame.size.height * 0.85);
    // 监听按钮
    [startButton addTarget:self action:@selector(startBtnClick) forControlEvents:UIControlEventTouchUpInside];
    // 添加到图片上
    [imageView addSubview:startButton];
    
    
    //添加Label
    UILabel *label = [[UILabel alloc]init];
    
    label.text = @"战狼AP -- 高仿快医";
    
    label.textColor = [UIColor whiteColor];
    
    label.font = [UIFont boldSystemFontOfSize:20];
    
    label.textAlignment = NSTextAlignmentCenter;
    
    //设置frme
    label.frame = CGRectMake(0, 0, NQScreenW, 100);
    
    //设置中心点位置
    label.center = CGPointMake(imageView.frame.size.width * 0.5, imageView.frame.size.height * 0.3);
    
    [imageView addSubview:label];
}

/**
 *  立即体验
 */
- (void)startBtnClick {
    //登录控制器
    XZGRegisterViewController *registerVc = [[XZGRegisterViewController alloc] init];
    MORootNavigationController *navVc = [[MORootNavigationController alloc] initWithRootViewController:registerVc];
    
    [UIView animateWithDuration:0.3 animations:^{
        self.view.frame = CGRectMake(-self.view.frame.size.width, 0, self.view.frame.size.width, self.view.frame.size.height);
    } completion:^(BOOL finished) {
        // 移除控制器的view
        [self.view removeFromSuperview];
    }];
    
    // 会导致新特性界面销毁吗？不会，仅仅是引用计数减一
    [UIApplication sharedApplication].keyWindow.rootViewController = navVc;
    // 将控制器的view添加到窗口上
    [[UIApplication sharedApplication].keyWindow addSubview:self.view];
    
    //    [self.navigationController pushViewController:vc animated:NO];
    //    [self presentViewController:vc animated:NO completion:^{
    //        [self removeFromParentViewController];
    //    }];
}


//- (UIImageView *)imageView {
//    if (_imageView == nil) {
//        _imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"20150110105032223"]];
//    }
//    
//    return _imageView;
//}

@end
